home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-08-24 | 40.8 KB | 1,189 lines |
-
-
- sh(C) 06 January 1993
- sh(C)
-
-
- _N_a_m_e
-
- sh - invoke the shell command interpreter
-
- _S_y_n_t_a_x
-
- sshh [ --aacceeiikknnrrssttuuvvxx ] [ _aa_rr_gg_ss ]
-
- _D_e_s_c_r_i_p_t_i_o_n
-
- The shell is the standard command programming language that
- executes com-
- mands read from a terminal or a file. See ``Invocation''
- below for the
- meaning of arguments to the shell.
-
- _C_o_m_m_a_n_d_s
-
- A _s_i_m_p_l_e-_c_o_m_m_a_n_d is a sequence of nonblank _w_o_r_d_s separated by
- _b_l_a_n_k_s (a
- _b_l_a_n_k is a tab or a space). The first word specifies the
- name of the
- command to be executed. Except as specified below, the
- remaining words
- are passed as arguments to the invoked command. The command
- name is
- passed as argument 0 (see eexxeecc(S)). The _v_a_l_u_e of a simple-
- command is its
- exit status if it terminates normally, or (octal) 1000+_ss_tt_aa_tt_uu_ss
- if it ter-
- minates abnormally. See ssiiggnnaall(S) for a list of status val-
- ues.
-
- A _p_i_p_e_l_i_n_e is a sequence of one or more _c_o_m_m_a_n_d_s separated by
- a vertical
- bar (||). (The caret (^^), is an obsolete synonym for the ver-
- tical bar and
- should not be used in a pipeline. Scripts that use ``^'' for
- pipelines
- are incompatible with the Korn shell.) The standard output
- of each com-
- mand but the last is connected by a ppiippee(S) to the standard
- input of the
- next command. Each command is run as a separate process; the
- shell waits
- for the last command to terminate.
-
- A _l_i_s_t is a sequence of one or more pipelines separated by ;;,
- &&, &&&&, or
- ||||, and optionally terminated by ;; or &&. Of these four sym-
- bols, ;; and &&
- have equal precedence, which is lower than that of &&&& and ||||.
- The sym-
- bols &&&& and |||| also have equal precedence. A semicolon (;;)
- causes
- sequential execution of the preceding pipeline; an ampersand
- (&&) causes
- asynchronous execution of the preceding pipeline (that is,
- the shell does
- _n_o_t wait for that pipeline to finish). The symbol &&&& (||||)
- causes the
- _l_i_s_t following it to be executed only if the preceding
- pipeline returns a
- zero (nonzero) exit status. An arbitrary number of newlines
- may appear
- in a _l_i_s_t, instead of semicolons, to delimit commands.
-
- A _c_o_m_m_a_n_d is either a simple-command or one of the following
- commands.
- Unless otherwise stated, the value returned by a command is
- that of the
- last simple-command executed in the command:
-
- ffoorr _nn_aa_mm_ee [ iinn _ww_oo_rr_dd ... ]
- ddoo
- _ll_ii_ss_tt
- ddoonnee
-
- Each time a ffoorr command is executed, _nn_aa_mm_ee is set to the next
- _ww_oo_rr_dd taken
- from the iinn _ww_oo_rr_dd list. If iinn _ww_oo_rr_dd is omitted, then the ffoorr
- command exe-
- cutes the ddoo _ll_ii_ss_tt once for each positional parameter that is
- set (see
- ``Parameter substitution'' below). Execution ends when there
- are no more
- words in the list.
-
-
- ccaassee _ww_oo_rr_dd iinn
- [ _pp_aa_tt_tt_ee_rr_nn [ | _pp_aa_tt_tt_ee_rr_nn ] ... )) _ll_ii_ss_tt
- ;;;; ]
- eessaacc
-
- A ccaassee command executes the _ll_ii_ss_tt associated with the first
- _pp_aa_tt_tt_ee_rr_nn that
- matches _ww_oo_rr_dd. The form of the patterns is the same as that
- used for
- filename generation (see ``Filename generation'' below).
-
-
- iiff _ll_ii_ss_tt
- tthheenn
- _ll_ii_ss_tt
- [ eelliiff _ll_ii_ss_tt tthheenn
- _ll_ii_ss_tt ]
- ...
- [ eellssee _ll_ii_ss_tt ]
- ffii
-
- The _ll_ii_ss_tt following iiff is executed and, if it returns a zero
- exit status,
- the _ll_ii_ss_tt following the first tthheenn is executed. Otherwise,
- the _ll_ii_ss_tt fol-
- lowing eelliiff is executed and, if its value is zero, the _ll_ii_ss_tt
- following the
- next tthheenn is executed. Failing that, the eellssee _ll_ii_ss_tt is exe-
- cuted. If no
- eellssee _ll_ii_ss_tt or tthheenn _ll_ii_ss_tt is executed, then the iiff command
- returns a zero
- exit status.
-
-
- wwhhiillee _ll_ii_ss_tt
- ddoo
- _ll_ii_ss_tt
- ddoonnee
-
- A wwhhiillee command repeatedly executes the wwhhiillee _ll_ii_ss_tt and, if
- the exit
- status of the last command in the list is zero, executes the
- ddoo _ll_ii_ss_tt;
- otherwise the loop terminates. If no commands in the ddoo _ll_ii_ss_tt
- are exe-
- cuted, then the wwhhiillee command returns a zero exit status;
- uunnttiill may be
- used in place of wwhhiillee to negate the loop termination test.
-
-
- uunnttiill _ll_ii_ss_tt
- ddoo
- _ll_ii_ss_tt
- ddoonnee
-
- uunnttiill is similar to wwhhiillee, only uunnttiill continues execution
- until the first
- _ll_ii_ss_tt returns a zero exit status. In other words, uunnttiill works
- until the
- test condition succeeds (it works the whole time the command
- is failing);
- wwhhiillee works until the test condition fails. uunnttiill is useful
- when you are
- waiting for a particular event to occur.
-
-
- ((_ll_ii_ss_tt))
-
- Executes _ll_ii_ss_tt in a subshell.
-
-
- {{_ll_ii_ss_tt;;}}
-
- _ll_ii_ss_tt is simply executed.
-
-
- _nn_aa_mm_ee (()) {{_ll_ii_ss_tt;;}}
-
- Define a function which is referenced by _nn_aa_mm_ee. The body of
- functions is
- the _ll_ii_ss_tt of commands between {{ and }}. Execution of functions
- is
- described later (see ``Execution''.)
-
- The following words are recognized only as the first word of
- a command
- and when not quoted:
-
- iiff tthheenn eellssee eelliiff ffii ccaassee eessaacc
- ffoorr wwhhiillee uunnttiill ddoo ddoonnee {{ }}
-
- _C_o_m_m_e_n_t_s
-
- A word beginning with ## causes that word and all the follow-
- ing characters
- up to a newline to be ignored.
-
- _C_o_m_m_a_n_d _s_u_b_s_t_i_t_u_t_i_o_n
-
- The standard output from a command enclosed between grave
- accents ( `` `` )
- may be used as part or all of a word; trailing newlines are
- removed.
-
- No interpretation is done on the command string before the
- string is
- read, except to remove backslashes ( used to escape other
- characters.
- Backslashes may be used to escape grave accents (``) or other
- backslashes
- and are removed before the command string is read. Escaping
- grave
- accents allows nested command substitution. If the command
- substitution
- lies within a pair of double quotes ( "" `` ...... `` "" ), back-
- slashes used to
- escape a double quote (
- intact.
-
- If a backslash is used to escape a newline character, both
- the backslash
- and the newline are removed (see the section on ``Quoting'').
- In addi-
- tion, backslashes used to escape dollar signs ($ ) are
- removed. Since
- no interpretation is done on the command string before it is
- read,
- inserting a backslash to escape a dollar sign has no effect.
- Backslashes
- that precede characters other than ``, "", nneewwlliinnee, and $$ are
- left
- intact.
-
- _P_a_r_a_m_e_t_e_r _s_u_b_s_t_i_t_u_t_i_o_n
-
- The character $$ is used to introduce substitutable
- _p_a_r_a_m_e_t_e_r_s. There are
- two types of parameters, positional and keyword. If
- _p_a_r_a_m_e_t_e_r is a
- digit, it is a positional parameter. Positional parameters
- may be
- assigned values by sseett. Keyword parameters, (also known as
- variables)
- may be assigned values by writing:
-
- _nn_aa_mm_ee _== _vv_aa_ll_uu_ee [ _nn_aa_mm_ee _== _vv_aa_ll_uu_ee ] ...
-
- Pattern-matching is not performed on _vv_aa_ll_uu_ee. There cannot be
- a function
- and a variable with the same name.
-
- $${{_pp_aa_rr_aa_mm_ee_tt_ee_rr}}
- A _pp_aa_rr_aa_mm_ee_tt_ee_rr is a sequence of letters, digits, or under-
- scores (a
- _n_a_m_e), a digit, or any of the characters **, @@, ##, ??, --,
- $$, and !!.
- The value, if any, of the parameter is substituted. The
- braces are
- required only when _pp_aa_rr_aa_mm_ee_tt_ee_rr is followed by a letter,
- digit, or
- underscore that is not to be interpreted as part of its
- name. A
- _n_a_m_e must begin with a letter or underscore. If
- _pp_aa_rr_aa_mm_ee_tt_ee_rr is a
- digit then it is a positional parameter. If _pp_aa_rr_aa_mm_ee_tt_ee_rr
- is ** or @@,
- then all the positional parameters, starting with $$11,
- are substi-
- tuted (separated by spaces). Parameter $$00 is set from
- argument zero
- when the shell is invoked.
-
- $${{_pp_aa_rr_aa_mm_ee_tt_ee_rr::--_ww_oo_rr_dd}}
- If _pp_aa_rr_aa_mm_ee_tt_ee_rr is set and is not a null argument, substi-
- tute its
- value; otherwise substitute _ww_oo_rr_dd.
-
- $${{_pp_aa_rr_aa_mm_ee_tt_ee_rr::==_ww_oo_rr_dd}}
- If _pp_aa_rr_aa_mm_ee_tt_ee_rr is not set or is null, then set it to _ww_oo_rr_dd;
- the value
- of the parameter is then substituted. Positional param-
- eters may not
- be assigned to in this way.
-
- $${{_pp_aa_rr_aa_mm_ee_tt_ee_rr::??_ww_oo_rr_dd}}
- If _pp_aa_rr_aa_mm_ee_tt_ee_rr is set and is not a null argument, substi-
- tute its
- value; otherwise, print _ww_oo_rr_dd and exit from the shell.
- If _ww_oo_rr_dd is
- omitted, the message ``parameter null or not set'' is
- printed.
-
- $${{_pp_aa_rr_aa_mm_ee_tt_ee_rr::++_ww_oo_rr_dd}}
- If _pp_aa_rr_aa_mm_ee_tt_ee_rr is set and is not a null argument, substi-
- tute _ww_oo_rr_dd;
- otherwise substitute nothing.
-
- In the above, _ww_oo_rr_dd is not evaluated unless it is to be used
- as the sub-
- stituted string, so that in the following example, ppwwdd is
- executed only
- if dd is not set or is null:
-
- eecchhoo $${{dd::--((ggaappwwdd``}}
-
- If the colon (::) is omitted from the above expressions, then
- the shell
- only checks whether _pp_aa_rr_aa_mm_ee_tt_ee_rr is set.
-
- The following parameters are automatically set by the shell:
-
- ## The number of positional parameters in decimal
-
- -- Flags supplied to the shell on invocation or by the sseett
- command
-
- ?? The decimal value returned by the last synchronously
- executed com-
- mand
-
- $$ The process number of this shell
-
- !! The process number of the last background command
- invoked
-
- The following parameters are used by the shell:
-
- CCDDPPAATTHH Defines search path for the ccdd command. See
- the section
- ``cd'' under ``Special commands'' below.
-
- HHOOMMEE The default argument (home directory) for the
- ccdd command
-
- PPAATTHH The search path for commands (see ``Execution''
- below)
-
- MMAAIILL If this variable is set to the name of a mail
- file, then
- the shell informs the user of the arrival of
- mail in the
- specified file
-
- MMAAIILLCCHHEECCKK This parameter specifies how often (in seconds)
- the shell
- will check for the arrival of mail in the files
- specified
- by the MMAAIILLPPAATTHH or MMAAIILL parameters. The
- default value is
- 600 seconds (10 minutes). If set to 0, the
- shell will
- check before each prompt.
-
- MMAAIILLPPAATTHH A colon ((::)) separated list of filenames. If
- this parameter
- is set, the shell informs the user of the
- arrival of mail
- in any of the specified files. Each filename
- can be fol-
- lowed by ``%'' and a message that will be
- printed when the
- modification time changes. The default message
- is
- ``you have mail''.
-
- PPSS11 Primary prompt string, by default ``$$ ''
-
- PPSS22 Secondary prompt string, by default ``>> ''
-
- IIFFSS Internal field separators, normally ssppaaccee, ttaabb,
- and nneewwlliinnee
-
- SSHHEELLLL When the shell is invoked, it scans the envi-
- ronment (see
- ``Environment'' below) for this name. If it is
- found and
- there is an `r' in the file name part of its
- value, the
- shell becomes a restricted shell.
-
- The shell gives default values to PPAATTHH, PPSS11, PPSS22, and IIFFSS,
- while HHOOMMEE and
- MMAAIILL are not set at all by the shell (although HHOOMMEE _i_s set by
- llooggiinn(M)).
-
- _B_l_a_n_k _i_n_t_e_r_p_r_e_t_a_t_i_o_n
-
- After parameter and command substitution, the results of sub-
- stitution are
- scanned for internal field separator characters (those found
- in IIFFSS) and
- split into distinct arguments where such characters are
- found. Explicit
- null arguments ( """" or '''' ) are retained. Implicit null
- arguments (those
- resulting from _pp_aa_rr_aa_mm_ee_tt_ee_rr_ss that have no values) are removed.
-
- _F_i_l_e_n_a_m_e _g_e_n_e_r_a_t_i_o_n
-
- Following substitution, each command _ww_oo_rr_dd is scanned for the
- characters
- **, ??, and [[. If one of these characters appears, the word is
- regarded as
- a _pp_aa_tt_tt_ee_rr_nn. The word is replaced with alphabetically sorted
- filenames
- that match the pattern. If no filename is found that matches
- the pat-
- tern, the word is left unchanged. The character ``.'' at the
- start of a
- filename or immediately following a ``/'', as well as the
- character ``/''
- itself, must be matched explicitly. These characters and
- their matching
- patterns are:
-
- ** Matches any string, including the null string.
-
- ?? Matches any single character.
-
- [[...]] Matches any one of the enclosed characters. A pair of
- characters
- separated by ``-'' matches any character lexically
- between the
- pair, inclusive. If the first character following the
- opening
- bracket ([[) is an exclamation mark (!!), then any char-
- acter not
- enclosed is matched.
-
- _Q_u_o_t_i_n_g
-
- The following characters have a special meaning to the shell
- and cause
- termination of a word unless quoted:
-
- ; & ( ) | ^ < > newline space tab
-
- A character may be _q_u_o_t_e_d (that is, made to stand for itself)
- by preced-
- ing it with a ``''. The pairneewwlliinnee is ignored. All charac-
- ters
- enclosed between a pair of single quotation marks ('' ''),
- except a single
- quotation mark, are quoted. Inside double quotation marks (""
- ""), parame-
- ter and command substitution occurs and ``'' quotes the char-
- acters ``,
- "", and $$. ""$$**"" is equivalent to ""$$11 $$22 ..."", whereas ""$$@@"" is
- equivalent
- to ""$$11"" ""$$22"" ...
-
- _P_r_o_m_p_t_i_n_g
-
- When used interactively, the shell prompts with the value of
- PPSS11 before
- reading a command. If at any time a newline is typed and
- further input
- is needed to complete a command, the secondary prompt (that
- is, the value
- of PPSS22) is issued.
-
- _S_p_e_l_l_i_n_g _c_h_e_c_k_e_r
-
- When using ccdd(C) the shell checks spelling. For example, if
- you change
- to a different directory using ccdd and misspell the directory
- name, the
- shell responds with an alternative spelling of an existing
- directory.
- Enter ``y'' and press <Return> (or just press <Return>) to
- change to the
- offered directory. If the offered spelling is incorrect,
- enter ``n'',
- then retype the command line. In this example the sshh(C)
- response is
- boldfaced:
-
- $ cd /usr/spol/uucp
- ccdd //uussrr//ssppooooll//uuuuccpp??y
- ookk
-
-
- _I_n_p_u_t/_O_u_t_p_u_t
-
- Before a command is executed, its input and output may be
- redirected
- using a special notation interpreted by the shell. The fol-
- lowing may
- appear anywhere in a simple-command or may precede or follow
- a command.
- They are _n_o_t passed on to the invoked command; substitution
- occurs before
- _ww_oo_rr_dd or _dd_ii_gg_ii_tt is used:
-
- <<_ww_oo_rr_dd Use file _ww_oo_rr_dd as standard input (file descrip-
- tor 0).
-
- >>_ww_oo_rr_dd Use file _ww_oo_rr_dd as standard output (file descrip-
- tor 1). If
- the file does not exist, it is created; other-
- wise, it is
- truncated to zero length.
-
- >>>>_ww_oo_rr_dd Use file _ww_oo_rr_dd as standard output. If the file
- exists, out-
- put is appended to it (by first seeking the
- end-of-file);
- otherwise, the file is created.
-
- <<<<[--]_ww_oo_rr_dd The shell input is read up to a line that is
- the same as
- _ww_oo_rr_dd, or to an end-of-file. The resulting doc-
- ument becomes
- the standard input. If any character of _ww_oo_rr_dd
- is quoted, no
- interpretation is placed upon the characters of
- the docu-
- ment; otherwise, parameter and command substi-
- tution occurs,
- (unescaped)neewwlliinnee is ignored, and ``'' must be
- used to
- quote the characters $$, ``, and the first char-
- acter of
- _ww_oo_rr_dd. If ``-'' is appended to <<<<, all leading
- tabs are
- stripped from _ww_oo_rr_dd and from the document.
-
- <<&&_dd_ii_gg_ii_tt The standard input is duplicated from file
- descriptor _dd_ii_gg_ii_tt
- (see dduupp(S)). Similarly for the standard out-
- put using >>.
-
- <<&&-- The standard input is closed. Similarly for
- the standard
- output using >>.
-
- If one of the above is preceded by a digit, the file descrip-
- tor created
- is that specified by the digit (instead of the default 0 or
- 1). For
- example:
-
- ...... 22>>&&11
-
- creates file descriptor 2 that is a duplicate of file
- descriptor 1.
-
- If a command is followed by ``&'', the default standard input
- for the
- command is the empty file /_d_e_v/_n_u_l_l. Otherwise, the environ-
- ment for the
- execution of a command contains the file descriptors of the
- invoking
- shell as modified by input/output specifications.
-
- _E_n_v_i_r_o_n_m_e_n_t
-
- The _e_n_v_i_r_o_n_m_e_n_t (see eennvviirroonn(M)) is a list of name-value
- pairs that is
- passed to an executed program in the same way as a normal
- argument list.
- The shell interacts with the environment in several ways. On
- invocation,
- the shell scans the environment and creates a parameter for
- each name
- found, giving it the corresponding value. Executed commands
- inherit the
- same environment. If the user modifies the values of these
- parameters or
- creates new ones, none of these affect the environment unless
- the eexxppoorrtt
- command is used to bind the shell's parameter to the environ-
- ment. The
- environment seen by any executed command is composed of any
- unmodified
- name-value pairs originally inherited by the shell, minus any
- pairs
- removed by uunnsseett, plus any modifications or additions, all of
- which must
- be noted in eexxppoorrtt commands.
-
- The environment for any _s_i_m_p_l_e-_c_o_m_m_a_n_d may be augmented by
- prefixing it
- with one or more assignments to parameters. Thus:
-
- TTEERRMM==wwyy6600 _cc_mm_dd _aa_rr_gg_ss
-
- and
-
- (eexxppoorrtt TTEERRMM; TTEERRMM==wwyy6600; _cc_mm_dd _aa_rr_gg_ss)
-
- are equivalent (as far as the above execution of _cc_mm_dd is con-
- cerned).
-
- If the --kk flag is set, _a_l_l keyword arguments are placed in
- the environ-
- ment, even if they occur after the command name.
-
- _S_i_g_n_a_l_s
-
- The IINNTTEERRRRUUPPTT and QQUUIITT signals for an invoked command are
- ignored if the
- command is followed by ``&''; otherwise signals have the val-
- ues inherited
- by the shell from its parent, with the exception of signal
- 11. See the
- ttrraapp command below.
-
- _E_x_e_c_u_t_i_o_n
-
- Each time a command is executed, the above substitutions are
- carried out.
- If the command name does not match a _s_p_e_c_i_a_l _c_o_m_m_a_n_d, but
- matches the
- name of a defined function, the function is executed in the
- shell process
- (note how this differs from the execution of shell proce-
- dures). The posi-
- tional parameters $$11,, $$22, ... are set to the arguments of the
- function.
- If the command name matches neither a _s_p_e_c_i_a_l _c_o_m_m_a_n_d nor the
- name of a
- defined function, a new process is created and an attempt is
- made to exe-
- cute the command via eexxeecc(S).
-
- The shell parameter PPAATTHH defines the search path for the
- directory con-
- taining the command. Alternative directory names are sepa-
- rated by a
- colon (::). The default path is :/_b_i_n:/_u_s_r/_b_i_n (specifying
- the current
- directory, /_b_i_n, and /_u_s_r/_b_i_n, in that order). Note that the
- current
- directory is specified by a null pathname, which can appear
- immediately
- after the equal sign or between the colon delimiters anywhere
- else in the
- path list. If the command name contains a ``/'', then the
- search path is
- not used. Otherwise, each directory in the path is searched
- for an exe-
- cutable file. If the file has execute permission but is not
- an _a._o_u_t
- file, it is assumed to be a file containing shell commands.
- A subshell
- (that is, a separate process) is spawned to read it. A
- parenthesized
- command is also executed in a subshell.
-
- Shell procedures are often used by users running the ccsshh.
- However, if
- the first character of the procedure is a ``#'' (comment
- character), ccsshh
- assumes the procedure is a ccsshh script, and invokes //bbiinn//ccsshh
- to execute
- it. Always start sshh procedures with some other character if
- ccsshh users are
- to run the procedure at any time. This invokes the standard
- shell
- //bbiinn//sshh.
-
- The location in the search path where a command was found is
- remembered
- by the shell (to help avoid unnecessary eexxeeccs later). If the
- command was
- found in a relative directory, its location must be re-
- determined when-
- ever the current directory changes. The shell forgets all
- remembered
- locations whenever the PPAATTHH variable is changed or the hhaasshh
- --rr command is
- executed (see hhaasshh in next section).
-
- _S_p_e_c_i_a_l _c_o_m_m_a_n_d_s
-
- Input/output redirection is permitted for these commands:
-
- :: No effect; the command does nothing. A zero exit code
- is returned.
-
- .. _ff_ii_ll_ee
- Reads and executes commands from _ff_ii_ll_ee and returns. The
- search path
- specified by PPAATTHH is used to find the directory contain-
- ing _ff_ii_ll_ee.
-
- bbrreeaakk [ _nn ]
- Exits from the enclosing ffoorr, wwhhiillee, or uunnttiill loop, if
- any. If _nn is
- specified, it breaks _nn levels.
-
- ccoonnttiinnuuee [ _nn ]
- Resumes the next iteration of the enclosing ffoorr, wwhhiillee,
- or uunnttiill
- loop. If _nn is specified, it resumes at the _nn-th enclos-
- ing loop.
-
- ccdd [ _aa_rr_gg ]
- Changes the current directory to _aa_rr_gg. The shell parame-
- ter HHOOMMEE is
- the default _aa_rr_gg. The shell parameter CCDDPPAATTHH defines the
- search path
- for the directory containing _aa_rr_gg. Alternative directory
- names are
- separated by a colon (:). The default path is <null>
- (specifying
- the current directory). Note that the current directory
- is speci-
- fied by a null path name, which can appear immediately
- after the
- equal sign or between the colon delimiters anywhere else
- in the path
- list. If _aa_rr_gg begins with a ``/'', the search path is
- not used.
- Otherwise, each directory in the path is searched for
- _aa_rr_gg.
-
- If the shell is reading its commands from a terminal,
- and the speci-
- fied directory does not exist (or some component cannot
- be
- searched), spelling correction is applied to each compo-
- nent of
- _d_i_r_e_c_t_o_r_y, in a search for the ``correct'' name. The
- shell then
- asks whether or not to try and change directory to the
- corrected
- directory name; an answer of nn means ``no'', and any-
- thing else is
- taken as ``yes''.
-
- eecchhoo [ _aa_rr_gg ]
- Writes arguments separated by blanks and terminated by a
- newline on
- the standard output. Arguments may be enclosed in
- quotes. bQuotes
- Bare required so that the shell correctly interprets
- these speacial
- cescape sequences:
- k
- s
- p f Form feed
- ran CNaerwrliiangee return
- c
- te Tab
- Vertical tab
- \ Backslash
- _nn The 8-bit character whose ASCII code is the 1, 2
- or 3-digit
- octal number _nn. _nn must start with a zero.
-
-
- eevvaall [ _aa_rr_gg ... ]
- The arguments are read as input to the shell and the
- resulting
- command(s) executed.
-
- eexxeecc [ _aa_rr_gg ... ]
- The command specified by the arguments is executed in
- place of this
- shell without creating a new process. Input/output
- arguments may
- appear and, if no other arguments are given, cause the
- shell
- input/output to be modified.
-
- eexxiitt [ _nn ]
- Causes the shell to exit with the exit status specified
- by _nn. If _nn
- is omitted, the exit status is that of the last command
- executed.
- An end-of-file will also cause the shell to exit.
-
- eexxppoorrtt [ _nn_aa_mm_ee ... ]
- The given _nn_aa_mm_ees are marked for automatic export to the
- _e_n_v_i_r_o_n_m_e_n_t
- of subsequently executed commands. If no arguments are
- given, a
- list of all names that are exported in this shell is
- printed.
-
- ggeettooppttss
- Used in shell scripts to support command syntax stan-
- dards (see
- IInnttrroo(C)); it parses positional parameters and checks
- for legal
- options. See ggeettooppttss(C) for usage and description.
-
- hhaasshh [ --rr ] [ _nn_aa_mm_ee ... ]
- For each _nn_aa_mm_ee, the location in the search path of the
- command speci-
- fied by _nn_aa_mm_ee is determined and remembered by the shell.
- The --rr
- option causes the shell to forget all remembered loca-
- tions. If no
- arguments are given, information about remembered
- commands is
- presented. ``Hits'' is the number of times a command
- has been
- invoked by the shell process. ``Cost'' is a measure of
- the work
- required to locate a command in the search path. There
- are certain
- situations which require that the stored location of a
- command be
- recalculated. Commands for which this will be done are
- indicated by
- an asterisk (**) adjacent to the ``hits'' information.
- ``Cost'' will
- be incremented when the recalculation is done.
-
- nneewwggrrpp [ _aa_rr_gg ... ]
- Equivalent to eexxeecc nneewwggrrpp _aa_rr_gg ...
-
- ppwwdd Print the current working directory. See ppwwdd(C) for
- usage and
- description.
-
- rreeaadd [ _nn_aa_mm_ee ... ]
- One line is read from the standard input and the first
- word is
- assigned to the first _nn_aa_mm_ee, the second word to the sec-
- ond _nn_aa_mm_ee,
- etc., with leftover words assigned to the last _nn_aa_mm_ee.
- The return
- code is 0 unless an end-of-file is encountered.
-
- rreeaaddoonnllyy [ _nn_aa_mm_ee ... ]
- The given _nn_aa_mm_ees are marked rreeaaddoonnllyy and the values of
- these _nn_aa_mm_ees
- may not be changed by subsequent assignment. If no
- arguments are
- given, a list of all rreeaaddoonnllyy names is printed.
-
- rreettuurrnn [ _nn ]
- Causes a function to exit with the return value speci-
- fied by _nn. If
- _nn is omitted, the return status is that of the last com-
- mand
- executed.
-
- sseett [ --aaeeffhhkknnuuvvxx [ _aa_rr_gg ... ] ]
-
- --aa Mark variables which are modified or created for
- export.
- --ee If the shell is noninteractive, exits immediately if
- a command
- exits with a nonzero exit status.
- --ff Disables filename generation.
- --hh Locates and remembers function commands as functions
- are defined
- (function commands are normally located when the
- function is
- executed). For example, if hh is set, /_b_i_n/_t_t_y is
- added to the
- hash table when:
-
- showtty(){
- tty
- }
-
- is declared. If hh is unset, the function is not
- added to the
- hash table until showtty is called.
- --kk Places all keyword arguments in the environment for
- a command,
- not just those that precede the command name.
- --nn Reads commands but does not execute them.
- --uu Treats unset variables as an error when substitut-
- ing.
- --vv Prints shell input lines as they are read.
- --xx Prints commands and their arguments as they are exe-
- cuted.
- Although this flag is passed to subshells, it does
- not enable
- tracing in those subshells.
- ---- Does not change any of the flags; useful in setting
- $1 to ``-''.
-
- Using ``+'' rather than ``-'' causes these flags to
- be turned
- off. These flags can also be used upon invocation
- of the shell.
- The current set of flags may be found in $$--. The
- remaining
- arguments are positional parameters and are
- assigned, in order,
- to $$11, $$22, ... If no arguments are given, the val-
- ues of all
- names are printed.
-
- sshhiifftt [_nn]
- The positional parameters from $$22 ... are renamed $$11
- ... If _nn is
- specified, shift the positional parameters by _nn places.
- sshhiifftt is the
- only way to access positional parameters above $$99.
-
- tteesstt Evaluates conditional expressions. See tteesstt(C) for usage
- and
- description.
-
- ttiimmeess
- Prints the accumulated user and system times for pro-
- cesses run from
- the shell.
-
- ttrraapp [ _aa_rr_gg ] [ _nn ] ...
- _aa_rr_gg is a command to be read and executed when the shell
- receives
- signal(s) _nn. (Note that _aa_rr_gg is scanned once when the
- trap is set
- and once when the trap is taken.) Trap commands are
- executed in
- order of signal number. The highest signal number
- allowed is 16.
- Any attempt to set a trap on a signal that was ignored
- on entry to
- the current shell is ineffective. An attempt to trap on
- signal 11
- (memory fault) produces an error. If _aa_rr_gg is absent, all
- trap(s) _nn
- are reset to their original values. If _aa_rr_gg is the null
- string, this
- signal is ignored by the shell and by the commands it
- invokes. If _nn
- is 0, the command _aa_rr_gg is executed on exit from the
- shell. The ttrraapp
- command with no arguments prints a list of commands
- associated with
- each signal number.
-
- ttyyppee [ _nn_aa_mm_ee ... ]
- For each _nn_aa_mm_ee, indicate how it would be interpreted if
- used as a
- command name.
-
- uulliimmiitt [ _nn ]
- imposes a size limit of _nn blocks on files written by the
- shell and
- its child processes (files of any size may be read). Any
- user may
- decrease the file size limit, but only the super user
- (_r_o_o_t) can
- increase the limit. With no argument, the current limit
- is printed.
- If no option is given and a number is specified, --ff is
- assumed.
-
- uunnsseett [ _nn_aa_mm_ee ... ]
- For each _nn_aa_mm_ee, remove the corresponding variable or
- function. The
- variables PPAATTHH, PPSS11, PPSS22, MMAAIILLCCHHEECCKK and IIFFSS cannot be
- unset.
-
- uummaasskk [ _oo_oo_oo ]
- The user file-creation mask is set to the octal number
- _oo_oo_oo where _oo
- is an octal digit (see uummaasskk(C)). If _oo_oo_oo is omitted,
- the current
- value of the mask is printed.
-
- wwaaiitt [ _nn ]
- Waits for the specified process to terminate, and
- reports the termi-
- nation status. If _nn is not given, all currently active
- child pro-
- cesses are waited for. The return code from this com-
- mand is always
- 0.
-
- _I_n_v_o_c_a_t_i_o_n
-
- If the shell is invoked through eexxeecc(S) and the first charac-
- ter of argu-
- ment 0 is ``-'', commands are initially read from
- /_e_t_c/_p_r_o_f_i_l_e and then
- from $$HHOOMMEE/._p_r_o_f_i_l_e, if such files exist. Thereafter, com-
- mands are read
- as described below, which is also the case when the shell is
- invoked as
- //bbiinn//sshh. The flags below are interpreted by the shell on
- invocation
- only; note that unless the --cc or --ss flag is specified, the
- first argument
- is assumed to be the name of a file containing commands, and
- the remain-
- ing arguments are passed as positional parameters to that
- command file:
-
- --cc _ss_tt_rr_ii_nn_gg If the --cc flag is present, commands are read from
- _ss_tt_rr_ii_nn_gg.
-
- --ss If the --ss flag is present or if no arguments
- remain, commands
- are read from the standard input. Any remaining
- arguments
- specify the positional parameters. Shell output is
- written to
- file descriptor 2.
-
- --tt If the --tt flag is present, a single command is read
- and exe-
- cuted, and the shell exits. This flag is intended
- for use by C
- programs only and is not useful interactively.
-
- --ii If the --ii flag is present or if the shell input and
- output are
- attached to a terminal, this shell is _i_n_t_e_r_a_c_t_i_v_e.
- In this
- case, TTEERRMMIINNAATTEE is ignored (so that kkiillll 00 does not
- kill an
- interactive shell) and IINNTTEERRRRUUPPTT is caught and
- ignored (so that
- wwaaiitt is interruptible). In all cases, QQUUIITT is
- ignored by the
- shell.
-
- --rr If the --rr flag is present, the shell is a
- restricted shell (see
- rrsshh(C)).
-
- The remaining flags and arguments are described under the sseett
- command
- above.
-
- _E_x_i_t _s_t_a_t_u_s
-
- Errors detected by the shell, such as syntax errors, cause
- the shell to
- return a nonzero exit status. If the shell is being used
- noninterac-
- tively, execution of the shell file is abandoned. Otherwise,
- the shell
- returns the exit status of the last command executed. See the
- eexxiitt com-
- mand above.
-
- _F_i_l_e_s
-
- /_e_t_c/_p_r_o_f_i_l_e system default _p_r_o_f_i_l_e, read by login shells
- before
- $$HHOOMMEE/._p_r_o_f_i_l_e
- $$HHOOMMEE/._p_r_o_f_i_l_e read by login shell at login
- /_t_m_p/_s_h* temporary file for <<<<
- /_d_e_v/_n_u_l_l source of empty file
-
- _S_e_e _a_l_s_o
-
- aa..oouutt(FP), ccdd(C), dduupp(S), eennvv(C), eennvviirroonn(M), eexxeecc(S),
- ffoorrkk(S), kksshh(C),
- llooggiinn(M), nneewwggrrpp(C), ppiippee(S), pprrooffiillee(M), rrsshh(C), ssiiggnnaall(S),
- tteesstt(C),
- uummaasskk(C), uummaasskk(S) and wwaaiitt(S).
-
- _N_o_t_e_s
-
- The command rreeaaddoonnllyy (without arguments) produces the same
- type of output
- as the command eexxppoorrtt.
-
- If <<<< is used to provide standard input to an asynchronous
- process
- invoked by &&, the shell gets mixed up about naming the input
- document; a
- garbage file /_t_m_p/_s_h* is created and the shell complains
- about not being
- able to find that file by another name.
-
- If a command is executed, and a command with the same name is
- installed
- in a directory in the search path before the directory where
- the original
- command was found, the shell will continue to eexxeecc the origi-
- nal command.
- Use the hhaasshh command to correct this situation.
-
- If you move the current directory or one above it, ppwwdd may
- not give the
- correct response. Use the ccdd command with a full pathname to
- correct
- this situation.
-
- When a sshh user logs in, the system reads and executes com-
- mands in
- /_e_t_c/_p_r_o_f_i_l_e before executing commands in the user's
- $$HHOOMMEE/._p_r_o_f_i_l_e. You
- can, therefore, modify the environment for all sshh users on
- the system by
- editing /_e_t_c/_p_r_o_f_i_l_e.
-
- The shell doesn't treat the high (eighth) bit in the charac-
- ters of a com-
- mand line argument specially, nor does it strip the eighth
- bit from the
- characters of error messages. Previous versions of the shell
- used the
- eighth bit as a quoting mechanism.
-
- Existing programs that set the eighth bit of characters in
- order to quote
- them as part of the shell command line should be changed to
- use of the
- standard shell quoting mechanisms (see the section on ``Quot-
- ing'').
-
- Words used to specify filenames in input/output redirection
- are not
- expanded for filename generation (see the section on ``File-
- name
- generation''). For example, ccaatt ffiillee11 >> aa** will create a
- file named _a*.
-
- Because commands in pipelines are run as separate processes,
- variables
- set in a pipeline have no effect on the parent shell.
-
- If you get the error message:
-
- fork failed - too many processes
-
- try using the wwaaiitt(C) command to clean up your background
- processes. If
- this doesn't help, the system process table is probably full
- or you have
- too many active foreground processes (there is a limit to the
- number of
- processes that be can associated with your login, and the
- number the sys-
- tem can keep track of).
-
- _W_a_r_n_i_n_g_s
-
- Not all processes of a 3 or more stage pipeline are children
- of the
- shell, and thus cannot be waited for.
-
- For wwaaiitt _nn, if _nn is not an active process id, all your
- shell's currently
- active background processes are waited for and the return
- code will be
- zero.
-
- _S_t_a_n_d_a_r_d_s _c_o_n_f_o_r_m_a_n_c_e
-
- sshh is conformant with:
-
- AT&T SVID Issue 2;
- and X/Open Portability Guide, Issue 3, 1989.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-